//
//  CycleListViewController.m
//  AppCommonUICollect
//
//  Created by ciyouzen on 2020/4/9.
//  Copyright © 2020 dvlproad. All rights reserved.
//

#import "CycleListViewController.h"
#import <Masonry/Masonry.h>
#import <CQDemoKit/CJUIKitToastUtil.h>
#import <CQCycleAdsKit/CQCycleAdsView.h>
#import <CQCycleAdsKit/CQCycleDescriptionsView.h>

@interface CycleListViewController ()

@end

@implementation CycleListViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = NSLocalizedString(@"测试循环栏", nil);
    
    // 正常广告栏
    NSMutableArray *imagesURLStrings = [[NSMutableArray alloc] init];
    for (NSInteger i = 0; i < 3; i++) {
        [imagesURLStrings addObject:@"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1587114231489&di=bbc6ae69e7855fda0810efba100c27f6&imgtype=0&src=http%3A%2F%2Fpic1.win4000.com%2Fwallpaper%2F6%2F581c2f6b12af5.jpg"];
    }
    
    UIImage *placeholderImage = [UIImage imageNamed:@"richu.jpg"];
    CQCycleAdsView *cycleView = [[CQCycleAdsView alloc] initWithPlaceholderImage:placeholderImage clickItemBlock:^(NSInteger index) {
        NSString *message = [NSString stringWithFormat:@"你点击了第%ld个", index];
        NSLog(@"%@", message);
    }];
    [cycleView setupUIWithImagesURLStrings:imagesURLStrings];
    [self.view addSubview:cycleView];
    [cycleView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.view).mas_offset(10);
        make.centerX.mas_equalTo(self.view);
        make.top.mas_equalTo(120);
        make.height.mas_equalTo(200);
    }];
    
    
    // 说明列表栏
    NSMutableArray *descriptionImageNames = [[NSMutableArray alloc] init];
    for (NSInteger i = 0; i < 23; i++) {
        [descriptionImageNames addObject:@"TSDemo_List.bundle/produceDescriptions.png"];
    }
    CQCycleDescriptionsView *descriptionsView = [[CQCycleDescriptionsView alloc] initWithPlaceholderImage:placeholderImage clickItemBlock:^(NSInteger index) {
        NSString *message = [NSString stringWithFormat:@"你点击了第%ld个", index];
        [CJUIKitToastUtil showMessage:message];
    }];
    [descriptionsView setupUIWithImageNames:descriptionImageNames];
    descriptionsView.backgroundColor = [UIColor redColor];
    [self.view addSubview:descriptionsView];
    [descriptionsView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.view).mas_offset(10);
        make.centerX.mas_equalTo(self.view);
        make.top.mas_equalTo(cycleView.mas_bottom).mas_offset(40);
        make.height.mas_equalTo(200);
    }];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
